#include"Com.h"
#include<sys/types.h>
#include<sys/ipc.h>
#include<sys/shm.h>
#include<unistd.h>

int main()
{
	key_t k = ftok(PATH,PROJ_ID);
	if(k<0)
	{
		perror("ftok");
		return 1;
	}
	printf("key:%x\n",k);
	printf("key:%d\n",k);

	int shmid = shmget(k,SIZE,IPC_CREAT|0644);
	if(shmid < 0)
	{
		perror("shmget");
		return 2;
	}
	char* shm_st = (char*)shmat(shmid,NULL,0);

	while(1)
	{
		printf("%s\n",shm_st);
		sleep(1);
	}
	shmdt(shm_st);

	shmctl(shmid,IPC_RMID,NULL);
	return 0;
}
